"""自动存储,好吧./不喜欢模型定义文件"""
from enum import Enum
from datetime import datetime
from typing_extensions import Annotated

from fastapi import Body
from pydantic import BaseModel, ConfigDict


class AutoSaveModel(BaseModel):
    """帖子的自动存储模型"""

    # 允许其他字段
    model_config = ConfigDict(extra='allow')

    as_uid: Annotated[int, Body(0, title="自动存储 ID")]
    as_subject: Annotated[str, Body("", max_length=255, title="标题")]
    as_content: Annotated[str, Body("", title="内容")]


class ResponseAutoSaveModel(BaseModel):
    """自动存储答案模型"""
    mb_id: str
    as_uid: int
    as_content: str
    as_subject: str
    as_id: int
    as_datetime: datetime

    class Config:
        from_attributes = True


class ResponseAutoSaveCountModel(BaseModel):
    """自动存储编号响应模型"""
    count: int


class ResponseAutoSaveDeleteModel(BaseModel):
    """自动存储删除响应模型"""
    result: str


class GoodType(Enum):
    """好吧./仇恨类型定义"""
    GOOD = 'good'
    NOGOOD = 'nogood'


class ResponseGoodModel(BaseModel):
    """好吧./不喜欢的反应模型"""
    status: str
    message: str
    good: int
    nogood: int


class Message(BaseModel):
    """消息响应模型 (API Docs)"""
    message: str


responses = {
    403: {"model": Message},
    404: {"model": Message},
    409: {"model": Message},
}
